//
//  HJTeamDetailVC.m
//  project
//
//  Created by hu on 2019/4/8.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJTeamDetailVC.h"
#import "HJTeamHeader.h"
#import "HJReceivedTeamView.h"
//#import "HJFightVC.h"
#import "YFDatePickerView.h"
#import "HJMapVC.h"

@interface HJTeamDetailVC ()<ReceivedDelegate>
@property (nonatomic,strong) HJTeamHeader * teamHeader;
@property (nonatomic,strong) HJReceivedTeamView * receiveView;
@end

@implementation HJTeamDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navTitle= @"收到组队详情";
    [self setupBtmButton];
}
-(void)configTableView {
    self.tableViewStyle = UITableViewStylePlain;
    [super configTableView];
    self.tableView.tableHeaderView = [self configTableHeaderView];
}

-(UIView *)configTableHeaderView {
    UIView * head = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 278+ 348)];
    
    HJTeamHeader * teamHeader = [[HJTeamHeader alloc]init];
    teamHeader.frame = CGRectMake(0, 0, SCREEN_WIDTH, 278);
    self.teamHeader = teamHeader;
    [head addSubview:teamHeader];
    
    HJReceivedTeamView * receiveView = [[HJReceivedTeamView alloc]initWithFrame:CGRectMake(0, teamHeader.bottom, SCREEN_WIDTH, 348)];
    receiveView.delegate = self;
    self.receiveView = receiveView;
    [head addSubview:receiveView];
    
    return head;
}
#pragma mark -- ReceivedDelegate
-(void)timeTFWithText:(UITextField *)text_tf {
    YFDatePickerView * datePicker = [YFDatePickerView datePickerView];
    [datePicker setSelectCompleted:^(NSString * _Nonnull year, NSString * _Nonnull month, NSString * _Nonnull day, NSString * _Nonnull hour, NSString * _Nonnull minute) {
        text_tf.text =[NSString stringWithFormat:@" %@/%@/%@ %@:%@",year, month, day, hour, minute];
    }];
    [datePicker show];
}

-(void)locationTFWithText:(UITextField *)text_tf {
    NSLog(@"见面地点");
    HJMapVC * mapVC = [[HJMapVC alloc]init];
    mapVC.locationBlock = ^(NSString * _Nonnull locationAdreess, CGFloat lng, CGFloat lat, NSString * _Nonnull cityId, NSString * _Nonnull city) {
        text_tf.text = locationAdreess;
    };
    [self.navigationController pushViewController:mapVC animated:YES];
}

-(void)otherInfoTVWithTextView:(UITextView *)textView {
    
}

-(void)isEditingBtnClikedWithIsEditing:(BOOL)isEdit {
    UIButton * releaseBtn = [self.view viewWithTag:1000];
    NSString * releaseStr;
    if (!isEdit) {
        releaseStr = @"修改并发送";
    }else {
        releaseStr = @"同意组队";
    }
    [releaseBtn setTitle:releaseStr forState:0];
}

- (void)setupBtmButton {
    CGFloat btnY = self.view.height - Height_TabBar-90;
    UIButton *releaseButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    releaseButton.tag =1000;
    releaseButton.frame = CGRectMake(48, btnY, SCREEN_WIDTH - 96, 68);
    [releaseButton setBackgroundImage:[UIImage imageNamed:@"releasebtn"] forState:(UIControlStateNormal)];
    [releaseButton setTitle:@"同意组队" forState:(UIControlStateNormal)];
    releaseButton.adjustsImageWhenHighlighted = NO;
    releaseButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    releaseButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 8, 0);
    [releaseButton addTarget:self action:@selector(teamDetailButtonClicked) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:releaseButton];
    
    UIButton *refusedButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    refusedButton.frame = CGRectMake(48+10, CGRectGetMaxY(releaseButton.frame)+10, SCREEN_WIDTH - 116, 40);
    [refusedButton setBackgroundImage:[UIImage imageNamed:@"btn1Line"] forState:(UIControlStateNormal)];
    [refusedButton setTitle:@"拒绝本次邀请" forState:(UIControlStateNormal)];
    refusedButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    refusedButton.adjustsImageWhenHighlighted = NO;
    [refusedButton setTitleColor:ColorRGB(251, 109, 105) forState:0];
    [refusedButton addTarget:self action:@selector(refusedButtonButtonClicked) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:refusedButton];
}

-(void)teamDetailButtonClicked {
    NSLog(@"同意");
}
-(void)refusedButtonButtonClicked {
    NSLog(@"拒绝");
}
@end
